// <copyright file="EasyWebApp.cs" company="<Customer Name>">This is a "work-for-hire". or Copyright (C) 2010 MicroCODE Incorporated Troy, MI</copyright><author><Class Author's Name></author>

/*
 *      Title:    <Class Description>
 *      Module:   ClassTemplate (<Namespace>:ClassTemplate.cs)
 *      Project:  <Project Name>
 *      Customer: <Customer Name>
 *      Facility: MicroCODE Incorporated
 *      Date:     <Class Creation Date>
 *      Author:   <Class Author's Name>
 * 
 * 
 * 
 *  
 *      MODIFICATIONS:
 *      --------------
 *
 *  Date:         By-Group:   Rev:     Description:
 *
 *  DD-Mmm-YYYY   XYZ-GROUP  {0001}    Describe reason for creating or modifying class... 
 * 
 * 
 * 
 */
using System.Xml.XPath;
using System.Xml.Xsl;
using Org.EasyWeb.Sys;

namespace Org.EasyWeb.Xml
{
    public abstract class BaseDoubleTransform : BaseTransform, IDoubleTransformAll, ITransformAll
    {
        // Fields
        private XsltArgumentList fArgs = new XsltArgumentList();
        private int fDocumentNumber;
        private bool fIsPost = false;
        private string fOperation;
        private PageStyle fStyle;
        private XPathNavigator[] fXmlDocuments;

        // Methods
        public BaseDoubleTransform()
        {
            this.fArgs.AddParam("IsPost", string.Empty, this.fIsPost);
        }

        public void SetDocumentNumber(int number, PageStyle style, string operation)
        {
            this.fDocumentNumber = number;
            this.fXmlDocuments = new XPathNavigator[number];
            this.fStyle = style;
            this.fOperation = operation;
        }

        public void SetXmlDocument(int i, XPathNavigator document)
        {
            this.fXmlDocuments[i] = document;
        }

        protected abstract string Transform(string xmlContent);
        public override string TransformContent(bool isIe)
        {
            return this.TransformContent(this[HtmlPosition.Content].GetXmlString());
        }

        protected string TransformContent(string xmlContent)
        {
            if (base.IsShowSource)
            {
                return xmlContent;
            }
            return this.Transform(xmlContent);
        }

        // Properties
        public XsltArgumentList Args
        {
            get
            {
                return this.fArgs;
            }
        }

        public int DocumentNumber
        {
            get
            {
                return this.fDocumentNumber;
            }
        }

        public bool IsPost
        {
            get
            {
                return this.fIsPost;
            }
            set
            {
                if (this.fIsPost != value)
                {
                    this.fIsPost = value;
                    this.fArgs.RemoveParam("IsPost", string.Empty);
                    this.fArgs.AddParam("IsPost", string.Empty, this.fIsPost);
                }
            }
        }

        public string Operation
        {
            get
            {
                return this.fOperation;
            }
        }

        public PageStyle Style
        {
            get
            {
                return this.fStyle;
            }
        }

        public XPathNavigator[] XmlDocuments
        {
            get
            {
                return this.fXmlDocuments;
            }
        }
    }
}